package com.gerenboke.controller;

import com.gerenboke.domain.ResponseResult;
import com.gerenboke.domain.dto.UserDto;
import com.gerenboke.domain.dto.UserSaveDto;
import com.gerenboke.domain.entity.User;
import com.gerenboke.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public ResponseResult userList(Long pageNum, Long pageSize, String userName, String phonenumber, String status) {
        return userService.userList(pageNum,pageSize,userName,phonenumber,status);
    }

    @PostMapping()
    public ResponseResult saveUser(@RequestBody UserSaveDto userSaveDto){
        return userService.saveUser(userSaveDto);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteUser(@PathVariable Long id) {
        return userService.deleteUser(id);
    }

    @GetMapping("/{id}")
    public ResponseResult selectUser(@PathVariable Long id) {
        return userService.selectUser(id);
    }

    @PutMapping("")
    public ResponseResult updateUser(@RequestBody UserDto userDto){
        return userService.updateUser(userDto);
    }
}
